package com.iofiledDemo;

import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;

public class A5 {


    public static void main(String[] args) {
        try {
            readFile();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static void readFile()throws  IOException {

        //     try {
        FileWriter writer = new FileWriter("D:/abc.txt");
        writer.write("人这一辈子不能太懦弱，这样的话就有人会瞧不起你的，碉堡你知道吗？你再这样下去会没女票的哦亲。。。");
        writer.flush();
        writer.close();

        FileReader reader = new FileReader("D:/abc.txt");
        FileWriter fw = new FileWriter("D:/a.txt");

        int num = 0;
        char[] chars = new char[10];
        while ((num = reader.read(chars)) != -1) {

//            reader.read(chars, 0, num);
//            String str = new String(chars);
            System.out.println(new String(chars,0,num));
            fw.write(new String(chars,0,num));
        }

        fw.flush();
        fw.close();
//        } catch (IOException e) {
//            e.printStackTrace();
//        }

        //  }


    }

}
